// Copyright (c) Appeon. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

using System;

namespace SnapObjects.Data.Informix 
{
    internal class InformixSqlStatementFactory : SqlStatementFactory
    {
        public InformixSqlStatementFactory(ISqlGenerationHelper helper, ITypeMapper mapper)
            : base(helper, mapper)
        {
        }

        public override ISqlBuilderParser GetBuilderParser(SqlStatementType statementType)
        {
            switch (statementType)
            {
                case SqlStatementType.Select:
                {
                    return new InformixQueryBuilderParser(this, _helper, _mapper);
                }
                case SqlStatementType.SqlRaw:
                {
                    return new InformixRawBuilderParser(this, _helper, _mapper);
                }
                case SqlStatementType.Insert:
                {
                    return new InformixInsertBuilderParser(this, _helper, _mapper);
                }
                case SqlStatementType.Update:
                {
                    return new InformixUpdateBuilderParser(this, _helper, _mapper);
                }
                case SqlStatementType.Delete:
                {
                    return new InformixDeleteBuilderParser(this, _helper, _mapper);
                }
                case SqlStatementType.Procedure:
                {
                    return new InformixProcedureBuilderParser(this, _helper, _mapper);
                }
                case SqlStatementType.Condition:
                {
                    return new InformixConditionBuilderParser(this, _helper, _mapper);
                }
                case SqlStatementType.Function:
                {
                    return new InformixFunctionBuilderParser(this, _helper, _mapper);
                }
                default:
                {
                    throw new NotSupportedException(statementType.ToString());
                }
            }
        }

        public override ISqlStatementGenerator GetSqlGenerator(SqlStatementType statementType)
        {
            ISqlStatementGenerator generator;

            switch (statementType)
            {
                case SqlStatementType.Select:
                {
                    generator = new InformixSqlSelectStatementGenerator(this, _helper, _mapper);
                }
                break;
                case SqlStatementType.Insert:
                {
                    generator = new InformixSqlInsertStatementGenerator(this, _helper, _mapper);
                }
                break;
                case SqlStatementType.Update:
                {
                    generator = new InformixSqlUpdateStatementGenerator(this, _helper, _mapper);
                }
                break;
                case SqlStatementType.Delete:
                {
                    generator = new InformixSqlDeleteStatementGenerator(this, _helper, _mapper);
                }
                break;
                case SqlStatementType.Procedure:
                {
                    generator = new InformixSqlProcedureStatementGenerator(this, _helper, _mapper);
                }
                break;
                case SqlStatementType.Condition:
                {
                    generator = new InformixSqlConditionStatementGenerator(this, _helper, _mapper);
                }
                break;
                case SqlStatementType.SqlRaw:
                {
                    generator = new InformixSqlRawStatementGenerator(this, _helper, _mapper);
                }
                break;
                case SqlStatementType.Function:
                {
                    generator = new InformixSqlFunctionStatementGenerator(this, _helper, _mapper);
                }
                break;
                default:
                {
                    throw new NotSupportedException(statementType.ToString());
                }
            }

            return generator;
        }

        public override ISqlStatementParser GetSqlParser(SqlStatementType statementType)
        {
            ISqlStatementParser parser;

            switch (statementType)
            {
                case SqlStatementType.Select:
                {
                    parser = new InformixSqlSelectStatementParser(this, _helper);
                }
                break;
                case SqlStatementType.Delete:
                {
                    parser = new InformixSqlDeleteStatementParser(this, _helper);
                }
                break;
                case SqlStatementType.Update:
                {
                    parser = new InformixSqlUpdateStatementParser(this, _helper);
                }
                break;
                case SqlStatementType.Insert:
                {
                    parser = new InformixSqlInsertStatementParser(this, _helper);
                }
                break;
                case SqlStatementType.Procedure:
                {
                    parser = new InformixSqlProcedureStatementParser(this, _helper);
                }
                break;
                case SqlStatementType.SqlRaw:
                {
                    parser = new InformixSqlRawStatementParser(this, _helper);
                }
                break;
                case SqlStatementType.Function:
                {
                    parser = new InformixSqlFunctionStatementParser(this, _helper);
                }
                break;
                default:
                {
                    throw new NotSupportedException(statementType.ToString());
                }
            }

            return parser;
        }
    }
}
